# -*- coding: utf-8 -*-
# @Time    : 2020/3/14 下午2:58
# @Author  : lilong

from abc import ABCMeta, abstractmethod


class Shape(metaclass=ABCMeta):
    """形状:抽象基类"""

    def __init__(self, color):
        self._color = color

    def getShapeInfo(self):
        return self._color.getColor() + "的" + self.getShapeType()

    @abstractmethod
    def getShapeType(self):
        pass


class Rectange(Shape):
    """矩形"""

    def __init__(self, color):
        super().__init__(color)

    def getShapeType(self):
        return "矩形"


class Ellipse(Shape):
    """椭圆"""

    def __init__(self, color):
        super().__init__(color)

    def getShapeType(self):
        return "椭圆"


class Color(metaclass=ABCMeta):
    """颜色：抽象基类"""

    @abstractmethod
    def getColor(self):
        pass


class Red(Color):
    """红色"""

    def getColor(self):
        return "红色"


class Green(Color):
    """绿色"""

    def getColor(self):
        return "绿色"


def testShap():
    redRect = Rectange(Red())
    print(redRect.getShapeInfo())

    greenRect = Rectange(Green())
    print(greenRect.getShapeInfo())

    redEllipse = Ellipse(Red())
    print(redEllipse.getShapeInfo())

    greenEllipse = Ellipse(Green())
    print(greenEllipse.getShapeInfo())


testShap()
